package com.credit.management.system.web.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.credit.management.system.model.Syuser;
import com.credit.management.system.service.ISyauthorityService;
@Controller
@RequestMapping(value="/home")
public class HomeController {
	@Autowired
	private ISyauthorityService syauthorityService;
	/**
	 * 进入主页面main.jsp
	 * @return
	 */
	@RequestMapping(value="/main",method=RequestMethod.GET)
	public String main(){
		
		return "common/main";
	}
	/**
	 * 主页面的首页，index.jsp
	 * @return
	 */
	@RequestMapping(value="/index")
	public String index(){
		//System.out.println("index--------controller----------");
		return "common/index_tea";
	}
	/**
	 * 主页面的头部。head.jsp
	 * @return
	 */
	@RequestMapping(value="/head",method=RequestMethod.GET)
	public String head(){
		
		return "common/head";
	}
	@RequestMapping(value="/left",method=RequestMethod.GET)
	public String left(){
		
		return "common/left";
	}
	
	@RequestMapping(value="/menu",method=RequestMethod.POST)
	@ResponseBody
	public List<Map<String,Object>> menu(HttpServletRequest request){
		HttpSession session=request.getSession();
		Syuser syuser=(Syuser) session.getAttribute("syuser");
		List<Map<String,Object>> maps=syauthorityService.findSyauthoritysByUserId(syuser.getId());
	return maps;
	}
}
